﻿Imports System.Security.Cryptography
Imports System.Text

Module modEncrypt
    Public Function Md5Encrypt(ByVal inputStr As String) As String
        Return Md5Encrypt(inputStr, New UTF8Encoding())
    End Function


    Public Function Md5Encrypt(ByVal inputStr As String, ByVal mEncodeing As Encoding) As String
        'MD5 md5 = New MD5CryptoServiceProvider();
        '    Byte[] t = md5.ComputeHash(encode.GetBytes(input));
        '    StringBuilder sb = New StringBuilder(32);
        '    For (Int() i = 0; i < t.Length; i++)
        '        sb.Append(t[i].ToString("x").PadLeft(2, '0'));
        '    return sb.ToString();
        Dim md5 As MD5 = New MD5CryptoServiceProvider()
        Dim t As Byte() = md5.ComputeHash(mEncodeing.GetBytes(inputStr))
        Dim sb As StringBuilder = New StringBuilder(32)
        For i As Integer = 0 To t.Length - 1
            sb.Append(t(i).ToString("x").PadLeft(2, "0"c))
        Next

        Return sb.ToString()

    End Function


End Module
